package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.TbIntroUser;
import com.laowang.project.system.service.TbIntroUserService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 推荐用户购买Controller
 * 
 * @author laowang
 * @date 2023-01-13
 */
@Api(tags = "推荐用户购买接口")
@RestController
@RequestMapping("/introUser")
public class TbIntroUserController extends BaseController {
    @Autowired
    private TbIntroUserService tbIntroUserService;

    /**
     * 查询推荐用户购买列表
     */
    @ApiOperation(value = "查询推荐用户购买列表",notes = "")
    @PreAuthorize("@ss.hasPermi('system:introUser:list')")
    @GetMapping("/list")
        public TableDataInfo list(TbIntroUser tbIntroUser) {
        startPage();
        List<TbIntroUser> list = tbIntroUserService.selectTbIntroUserList(tbIntroUser);
        return getDataTable(list);
    }
    
    /**
     * 导出推荐用户购买列表
     */
    @ApiOperation(value = "导出推荐用户购买列表",notes = "")
    @PreAuthorize("@ss.hasPermi('system:introUser:export')")
    @Log(title = "推荐用户购买", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbIntroUser tbIntroUser) {
        List<TbIntroUser> list = tbIntroUserService.selectTbIntroUserList(tbIntroUser);
        ExcelUtil<TbIntroUser> util = new ExcelUtil<TbIntroUser>(TbIntroUser.class);
        return util.exportExcel(list, "introUser");
    }

    /**
     * 获取推荐用户购买详细信息
     */
    @ApiOperation(value = "获取推荐用户购买详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('system:introUser:query')")
    @GetMapping(value = "/{introId}")
    public AjaxResult getInfo(@PathVariable("introId") Long introId) {
        return AjaxResult.success(tbIntroUserService.selectTbIntroUserById(introId));
    }

    /**
     * 新增推荐用户购买
     */
    @ApiOperation(value = "新增推荐用户购买",notes = "")
    @PreAuthorize("@ss.hasPermi('system:introUser:add')")
    @Log(title = "推荐用户购买", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbIntroUser tbIntroUser) {
        return toAjax(tbIntroUserService.insertTbIntroUser(tbIntroUser));
    }

    /**
     * 修改推荐用户购买
     */
    @ApiOperation(value = "修改推荐用户购买",notes = "")
    @PreAuthorize("@ss.hasPermi('system:introUser:edit')")
    @Log(title = "推荐用户购买", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbIntroUser tbIntroUser) {
        return toAjax(tbIntroUserService.updateTbIntroUser(tbIntroUser));
    }

    /**
     * 删除推荐用户购买
     */
    @ApiOperation(value = "删除推荐用户购买",notes = "")
    @PreAuthorize("@ss.hasPermi('system:introUser:remove')")
    @Log(title = "推荐用户购买", businessType = BusinessType.DELETE)
	@DeleteMapping("/{introIds}")
    public AjaxResult remove(@PathVariable Long[] introIds) {
        return toAjax(tbIntroUserService.deleteTbIntroUserByIds(introIds));
    }
}
